//
//  SCDetailEmoticon.swift
//  weibo
//
//  Created by 阿城 on 15/12/16.
//  Copyright © 2015年 阿城. All rights reserved.
//

import UIKit

class SCDetailEmoticon: UIImageView {
    
    private lazy var displayBtn: UIButton = UIButton()
    var showBtn: SCEmoticonButton?{
        didSet{
            displayBtn.setImage(showBtn?.currentImage, forState: UIControlState.Normal)
            displayBtn.setTitle(showBtn?.currentTitle, forState: UIControlState.Normal)
            displayBtn.titleLabel?.font = showBtn?.titleLabel?.font
            
            self.displayBtn.transform = CGAffineTransformMakeTranslation(0, 20)
            
            UIView.animateWithDuration(0.25, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 2, options: [], animations: { () -> Void in
                self.displayBtn.transform = CGAffineTransformIdentity
                }, completion: nil)
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI(){
        image = UIImage(named: "emoticon_keyboard_magnifier")
        layer.anchorPoint = CGPoint(x: 0.5, y: 0.8)
        sizeToFit()
        addSubview(displayBtn)
//        displayBtn.backgroundColor = UIColor.redColor()
        displayBtn.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(self)
            make.centerY.equalTo(self.snp_top).offset(30)
        }
    }
    
    
    
}
